const fs = require('fs');
const path = require('path');
let filePath = path.join(__dirname, 'dir/test.txt');
fs.exists(filePath,(r)=>{
    if(r){
        console.log('文件存在')
    }else{
        fs.writeFile(filePath,'test','utf8',(err)=>{
            if(err){
                console.log('文件写入失败')
            }else{
                console.log('文件写入成功');
            }
        })
    }
});